import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/layout'

// 工作台
import workbench from './modules/workbench'

// 园区管理 -- 楼宇管理
import parkManagement from './modules/parkManagement'

// 行车管理
import drivingManagement from './modules/drivingManagement'

// 物业费管理
import strataFeeManagement from './modules/strataFeeManagement'

// 一体杆管理
import allInoneRodManagement from './modules/allInoneRodManagement'

// 系统管理
import systemAdministration from './modules/systemAdministration'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/workbench',
    children: [{
      path: 'workbench',
      name: 'workbench',
      component: () => import('@/views/workbench/index')
    }]
  },
  {
    path: '/cardAdd',
    component: () => import('@/views/monthlyCardManagement/CarCard/add-card.vue')
  },
  {
    path: '/management/manageradd/:id?',
    name: 'manageradd',
    component: () => import('@/views/management/manager/add-manager.vue')
  },
  {
    path: '/management/detail/:id?',
    name: 'detail',
    component: () => import('@/views/management/manager/detail.vue')
  },
  {
    path: '/roleManagement/add/:id?',
    component: () => import('@/views/roleManagement/add.vue')

  },
  workbench,
  parkManagement,
  drivingManagement,
  strataFeeManagement,
  allInoneRodManagement,
  systemAdministration,
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
